package com.wenlin.myproduction.util;

import com.wenlin.myproduction.bean.GamePlayer;

import java.util.ArrayList;
import java.util.List;

import static com.wenlin.myproduction.util.ValGame.*;

/**
 * @author 文琳
 * @Email 377979485@qq.com
 * @desc
 * @time 2022-09-03 星期六 20:52
 */
public class ESportsManagerDataUtil {
    public static List<GamePlayer> getAll() {
        List<GamePlayer> list = new ArrayList<>();
        //按照战队录入，并且通过地区来补充
        list.add(new GamePlayer(DIS_HZ, PAR_AL, QUA_SR, PRO_PW, PRO2_CZ, POS_JUG, "xiaohao", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_AL, QUA_SR, PRO_JY, PRO2_CZ, POS_MID, "forge", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_AL, QUA_SR, PRO_JY, PRO2_XL, POS_ADC, "betty", YEA_2022));

        list.add(new GamePlayer(DIS_DB, PAR_BLG, QUA_SSR, PRO_JY, PRO2_CZ, POS_TOP, "bin", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_BLG, QUA_SSR, PRO_JY, PRO2_TN, POS_SUP, "crisp", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_BLG, QUA_SR, PRO_JY, PRO2_CZ, POS_MID, "fofo", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_BLG, QUA_SR, PRO_PW, PRO2_CZ, POS_ADC, "doggo", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_BLG, QUA_SR, PRO_PW, PRO2_DX, POS_JUG, "weiwei", YEA_2022));

        list.add(new GamePlayer(DIS_WY, PAR_EDG, QUA_SSR, PRO_SF, PRO2_CZ, POS_ADC, "viper", YEA_2022));
        list.add(new GamePlayer(DIS_WY, PAR_EDG, QUA_SSR, PRO_JY, PRO2_CZ, POS_MID, "scout", YEA_2022));
        list.add(new GamePlayer(DIS_XN, PAR_EDG, QUA_SSR, PRO_JY, PRO2_TN, POS_SUP, "meiko", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_EDG, QUA_SSR, PRO_ZB, PRO2_DX, POS_JUG, "jiejie", YEA_2022));
        list.add(new GamePlayer(DIS_HN, PAR_EDG, QUA_SSR, PRO_ZB, PRO2_ZT, POS_TOP, "Flandre", YEA_2022));

        list.add(new GamePlayer(DIS_WY, PAR_FPX, QUA_SR, PRO_SF, PRO2_DX, POS_JUG, "clid", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_FPX, QUA_SR, PRO_JY, PRO2_TN, POS_SUP, "hang", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_FPX, QUA_SR, PRO_SF, PRO2_CZ, POS_TOP, "xiaolaohu", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_FPX, QUA_SSR, PRO_ZB, PRO2_JM, POS_ADC, "lwx", YEA_2022));

        list.add(new GamePlayer(DIS_HZ, PAR_IG, QUA_SR, PRO_PW, PRO2_CZ, POS_JUG, "xun", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_IG, QUA_SR, PRO_SF, PRO2_CZ, POS_MID, "yuekai", YEA_2022));

        list.add(new GamePlayer(DIS_WY, PAR_JDG, QUA_SSR, PRO_SF, PRO2_ZT, POS_JUG, "kanavi", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_JDG, QUA_SSR, PRO_ZB, PRO2_ZT, POS_TOP, "369", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_JDG, QUA_SSR, PRO_SF, PRO2_CZ, POS_SUP, "missing", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_JDG, QUA_SR, PRO_JY, PRO2_CZ, POS_ADC, "hope", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_JDG, QUA_SR, PRO_JY, PRO2_CZ, POS_MID, "yagao", YEA_2022));

        list.add(new GamePlayer(DIS_WY, PAR_LNG, QUA_SSR, PRO_JY, PRO2_TN, POS_JUG, "tarzan", YEA_2022));
        list.add(new GamePlayer(DIS_WY, PAR_LNG, QUA_SSR, PRO_ZB, PRO2_GG, POS_MID, "doinb", YEA_2022));
        list.add(new GamePlayer(DIS_XN, PAR_LNG, QUA_SR, PRO_PW, PRO2_TN, POS_SUP, "Iwandy", YEA_2022));
        list.add(new GamePlayer(DIS_XN, PAR_LNG, QUA_SR, PRO_JY, PRO2_TN, POS_SUP, "lvmao", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_LNG, QUA_SSR, PRO_PW, PRO2_CZ, POS_ADC, "light", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_LNG, QUA_SR, PRO_ZB, PRO2_CZ, POS_TOP, "ale", YEA_2022));

        list.add(new GamePlayer(DIS_HZ, PAR_OMG, QUA_SR, PRO_PW, PRO2_TN, POS_SUP, "cold", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_OMG, QUA_SR, PRO_PW, PRO2_CZ, POS_ADC, "able", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_OMG, QUA_SR, PRO_SF, PRO2_CZ, POS_TOP, "shanji", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_OMG, QUA_SR, PRO_PW, PRO2_CZ, POS_MID, "creme", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_OMG, QUA_SR, PRO_SF, PRO2_CZ, POS_JUG, "aki", YEA_2022));

        list.add(new GamePlayer(DIS_XN, PAR_RA, QUA_SR, PRO_SF, PRO2_CZ, POS_MID, "strive", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_RA, QUA_SSR, PRO_JY, PRO2_JM, POS_TOP, "cube", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_RA, QUA_SR, PRO_PW, PRO2_DX, POS_ADC, "iboy", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_RA, QUA_SR, PRO_ZB, PRO2_ZT, POS_JUG, "leyan", YEA_2022));
        list.add(new GamePlayer(DIS_HN, PAR_RA, QUA_SR, PRO_JY, PRO2_ZT, POS_SUP, "yuyanjia", YEA_2022));

        list.add(new GamePlayer(DIS_DB, PAR_RNG, QUA_SSR, PRO_JY, PRO2_CZ, POS_TOP, "bin", YEA_2022));
        list.add(new GamePlayer(DIS_HB, PAR_RNG, QUA_SSR, PRO_SF, PRO2_CZ, POS_ADC, "gala", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_RNG, QUA_SSR, PRO_ZB, PRO2_JM, POS_MID, "xiaohu", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_RNG, QUA_SSR, PRO_ZB, PRO2_TN, POS_JUG, "wei", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_RNG, QUA_SR, PRO_PW, PRO2_XL, POS_TOP, "breathe", YEA_2022));
        list.add(new GamePlayer(DIS_HN, PAR_RNG, QUA_SSR, PRO_JY, PRO2_TN, POS_SUP, "ming", YEA_2022));

        list.add(new GamePlayer(DIS_DB, PAR_TES, QUA_SSR, PRO_ZB, PRO2_DX, POS_JUG, "tian", YEA_2022));
        list.add(new GamePlayer(DIS_XN, PAR_TES, QUA_SSR, PRO_JY, PRO2_TN, POS_SUP, "mark", YEA_2022));
        list.add(new GamePlayer(DIS_HB, PAR_TES, QUA_SR, PRO_SF, PRO2_ZT, POS_SUP, "zhuo", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_TES, QUA_SSR, PRO_ZB, PRO2_GG, POS_ADC, "jackylove", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_TES, QUA_SSR, PRO_SF, PRO2_CZ, POS_MID, "knight", YEA_2022));
        list.add(new GamePlayer(DIS_HN, PAR_TES, QUA_SSR, PRO_PW, PRO2_CZ, POS_TOP, "wayward", YEA_2022));

        list.add(new GamePlayer(DIS_XN, PAR_TT, QUA_SR, PRO_SF, PRO2_ZT, POS_ADC, "puff", YEA_2022));

        list.add(new GamePlayer(DIS_HZ, PAR_UP, QUA_SR, PRO_ZB, PRO2_ZT, POS_MID, "cryin", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_UP, QUA_SR, PRO_ZB, PRO2_DX, POS_TOP, "zoom", YEA_2022));
        list.add(new GamePlayer(DIS_HZ, PAR_UP, QUA_SR, PRO_PW, PRO2_CZ, POS_ADC, "elk", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_UP, QUA_SR, PRO_PW, PRO2_TN, POS_SUP, "shiauc", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_UP, QUA_SR, PRO_ZB, PRO2_DX, POS_JUG, "h4cker", YEA_2022));

        list.add(new GamePlayer(DIS_WY, PAR_V5, QUA_SSR, PRO_SF, PRO2_GG, POS_MID, "rookie", YEA_2022));
        list.add(new GamePlayer(DIS_WY, PAR_V5, QUA_SSR, PRO_SF, PRO2_CZ, POS_TOP, "rich", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_V5, QUA_SSR, PRO_PW, PRO2_ZT, POS_ADC, "photic", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_V5, QUA_SSR, PRO_ZB, PRO2_TN, POS_JUG, "karsa", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_V5, QUA_SR, PRO_JY, PRO2_GG, POS_SUP, "ppgod", YEA_2022));

        list.add(new GamePlayer(DIS_WY, PAR_WBG, QUA_SSR, PRO_ZB, PRO2_GG, POS_TOP, "theshy", YEA_2022));
        list.add(new GamePlayer(DIS_WY, PAR_WBG, QUA_SR, PRO_SF, PRO2_TN, POS_JUG, "sofm", YEA_2022));
        list.add(new GamePlayer(DIS_XN, PAR_WBG, QUA_SR, PRO_ZB, PRO2_CZ, POS_ADC, "huanfeng", YEA_2022));
        list.add(new GamePlayer(DIS_HD, PAR_WBG, QUA_SR, PRO_JY, PRO2_TN, POS_SUP, "swordart", YEA_2022));
        list.add(new GamePlayer(DIS_HN, PAR_WBG, QUA_SSR, PRO_ZB, PRO2_DX, POS_MID, "angel", YEA_2022));
        list.add(new GamePlayer(DIS_HN, PAR_WBG, QUA_SR, PRO_PW, PRO2_TN, POS_SUP, "on", YEA_2022));

        list.add(new GamePlayer(DIS_HD, PAR_WE, QUA_SR, PRO_SF, PRO2_TN, POS_JUG, "beishang", YEA_2022));
        list.add(new GamePlayer(DIS_HN, PAR_WE, QUA_SR, PRO_JY, PRO2_TN, POS_MID, "xiye", YEA_2022));
//        LogUtils.e("累计选手数" + list.size());
        return list;
    }

    /**
     * 根据给定的条件进行求交集搜索，列出所有满足条件的结果
     *
     * @param district 地区
     * @param party    战队
     * @param position 未知
     * @param pro      属性1
     * @param pro2     属性2
     * @param name     名称
     * @return 所求
     */
    public static List<GamePlayer> searchIntersection(String district, String party, String position, String pro, String pro2, String name) {
        LogUtils.e("条件district是" + district + "party是" + party + "position是" + position + "pro是" + pro + "pro2是" + pro2 + "name是" + name);
        List<GamePlayer> list = getAll();
        List<GamePlayer> result = new ArrayList<>();
        int score;
        if (Checker.hasList(list)) {
            for (GamePlayer gamePlayer :
                    list) {
                score = 0;
                if (Checker.hasWord(district)) {
                    if (!district.contains(gamePlayer.getDistrict())) continue;
                    else score++;
                }
                if (Checker.hasWord(party)) {
                    if (!party.contains(gamePlayer.getParty())) continue;
                    else score++;
                }
                if (Checker.hasWord(position)) {
                    if (!position.contains(gamePlayer.getPosition())) continue;
                    else score++;
                }
                if (Checker.hasWord(pro)) {
                    if (!pro.contains(gamePlayer.getPro())) continue;
                    else score++;
                }
                if (Checker.hasWord(pro2)) {
                    if (!pro2.contains(gamePlayer.getPro2())) continue;
                    else score++;
                }
                if (Checker.hasWord(name)) {
                    if (!gamePlayer.getName().toLowerCase().contains(name.toLowerCase())) continue;
                    else score++;
                }
                gamePlayer.setScore(score);
                result.add(gamePlayer);
            }
        }
        return result;
    }

    /**
     * 根据给定的条件进行求并集搜搜，列出所有满足条件的结果
     *
     * @param district 地区
     * @param party    战队
     * @param position 未知
     * @param pro      属性1
     * @param pro2     属性2
     * @param name     名称
     * @return 所求
     */
    public static List<GamePlayer> searchUnion(String district, String party, String position, String pro, String pro2, String name) {
        LogUtils.e("条件district是" + district + "party是" + party + "position是" + position + "pro是" + pro + "pro2是" + pro2 + "name是" + name);
        List<GamePlayer> list = getAll();
        List<GamePlayer> result = new ArrayList<>();
        int score;
        if (Checker.hasList(list)) {
            for (GamePlayer gamePlayer :
                    list) {
                if (Checker.hasWord(district) && district.contains(gamePlayer.getDistrict())) {
                    if (!result.contains(gamePlayer)) result.add(gamePlayer);
                    continue;
                }
                if (Checker.hasWord(party) && party.contains(gamePlayer.getParty())) {
                    if (!result.contains(gamePlayer)) result.add(gamePlayer);
                    continue;
                }
                if (Checker.hasWord(position) && position.contains(gamePlayer.getPosition())) {
                    if (!result.contains(gamePlayer)) result.add(gamePlayer);
                    continue;
                }
                if (Checker.hasWord(pro) && pro.contains(gamePlayer.getPro())) {
                    if (!result.contains(gamePlayer)) result.add(gamePlayer);
                    continue;
                }
                if (Checker.hasWord(pro2) && pro2.contains(gamePlayer.getPro2())) {
                    if (!result.contains(gamePlayer)) result.add(gamePlayer);
                    continue;
                }
                if (Checker.hasWord(name) && gamePlayer.getName().toLowerCase().contains(name.toLowerCase())) {
                    if (!result.contains(gamePlayer)) result.add(gamePlayer);
//                    continue;
                }
            }
            //统一针对结果进行检查，设置分数
            for (GamePlayer gamePlayer :
                    result) {
                score = 0;
                if (Checker.hasWord(district) && district.contains(gamePlayer.getDistrict())) {
                    score++;
                }
                if (Checker.hasWord(party) && party.contains(gamePlayer.getParty())) {
                    score++;
                }
                if (Checker.hasWord(position) && position.contains(gamePlayer.getPosition())) {
                    score++;
                }
                if (Checker.hasWord(pro) && pro.contains(gamePlayer.getPro())) {
                    score++;
                }
                if (Checker.hasWord(pro2) && pro2.contains(gamePlayer.getPro2())) {
                    score++;
                }
                if (Checker.hasWord(name) && gamePlayer.getName().toLowerCase().contains(name.toLowerCase())) {
                    score++;
                }
                gamePlayer.setScore(score);
            }
        }
        return result;
    }

}
